<?php
//保存编辑后的文章
session_start();
$title=$_POST['title'];
$class=$_POST['artclass'];
$postdata=getdate();
$content=$_POST['content'];
$Art_id=$_GET['Art_id'];
if($title=="" || $content=="")
{
    echo "<script>alert('标题或文章内容不能为空!!'); window.location.href='addart.php';</script>";
}
else
{
 function editart($title,$class,$postdata,$content,$Art_id)
{
require_once("conn.php");
    $sql_delart_num="UPDATE  artclass,artcontent SET artnum=artnum-1 WHERE Art_id='$Art_id' and artclass.cs_id=artcontent.cs_id";
    mysql_query($sql_delart_num) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/>SQL:".$sql);
    $sql_updata="update artcontent,artclass set Title='$title',artcontent.cs_id='$class',PostData=Now(),Content='$content' WHERE Art_id='$Art_id';";
    mysql_query($sql_updata) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/>SQL:".$sql); 
        $sql_addart_num="UPDATE  artclass SET artnum=artnum+1 WHERE cs_id='$class'";
    mysql_query($sql_addart_num) OR die("<br/>ERROR:<b>".mysql_error()."</b><br/>SQL:".$sql); 
    
    echo "<script>alert('修改成功!!'); window.location.href='artlist.php';</script>";
}
editart($title,$class,$postdata,$content,$Art_id);
}

?>